﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using OneMG.Phoenix.Service.Model;
using OneMG.Phoenix.Service.Contracts;
using OneMG.Phoenix.Service;

namespace OneMG.Phoenix.AdminSite.Views.Product
{
    public partial class Index : System.Web.UI.Page
    {
        IProductService IProduct = new ProductService();
        ICategoryService ICategory = new CategoryService();
        public  IList<ProductModel> listModle = new List<ProductModel>();
        public IList<CategoryModel> CategoryList = new List<CategoryModel>();
        public int CategoryID = 0;

 
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                CategoryList = ICategory.GetByParentID(2);
                BindData();
            }
        }

        private void BindData()
        {
            int total = 0;
            int.TryParse(Request.Form["sltCategoryID"], out CategoryID);
            listModle = IProduct.GetPagedList(AspNetPager1.PageSize, AspNetPager1.CurrentPageIndex, CategoryID, out total);
            AspNetPager1.RecordCount = total;

        }

        protected void AspNetPager1_PageChanged(object sender, EventArgs e)
        {
            BindData();
        }
    }
}
